package com.hgq.tenadmin.md.activity.controller;

import com.github.pagehelper.PageInfo;
import com.hgq.tenadmin.md.activity.param.FindParam;
import com.hgq.tenadmin.md.activity.service.MdActivityService;
import com.hgq.tencommon.common.R;
import com.hgq.tencommon.entity.md.activity.MdActivity;

import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/md/activity")
public class MdActivityController {
    @Resource
    private MdActivityService mdActivityService;
    @GetMapping("/list")
    public R list(FindParam findParam,int pageNum,int pageSize){
        PageInfo<MdActivity> allActivity = mdActivityService.findAllActivity(findParam, pageNum, pageSize);
        return R.ok(allActivity);
    }

    @PostMapping("/save")
    public R save(@RequestBody MdActivity mdActivity){
        mdActivityService.saveOneActivity(mdActivity);
        return R.ok();
    }
    @PostMapping("/updateActivity")
    public R update(@RequestBody MdActivity mdActivity){
        mdActivityService.updateOneActivity(mdActivity);
        return R.ok();
    }
    @GetMapping("/delById")
    public R update(Integer aid){
        System.out.println(aid);
        mdActivityService.removeOneActivity(aid);
        return R.ok();
    }
}
